package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysAppVersionMapper;
import com.ruoyi.system.domain.SysAppVersion;
import com.ruoyi.system.service.ISysAppVersionService;

/**
 * 程序版本Service业务层处理
 *
 * @author Felix
 * @date 2022-04-14
 */
@Service
public class SysAppVersionServiceImpl implements ISysAppVersionService {
    @Autowired
    private SysAppVersionMapper sysAppVersionMapper;

    /**
     * 查询程序版本
     *
     * @param id 程序版本ID
     * @return 程序版本
     */
    @Override
    public SysAppVersion selectSysAppVersionById(String id) {
        return sysAppVersionMapper.selectSysAppVersionById(id);
    }

    /**
     * 查询程序版本列表
     *
     * @param sysAppVersion 程序版本
     * @return 程序版本
     */
    @Override
    public List<SysAppVersion> selectSysAppVersionList(SysAppVersion sysAppVersion) {
        return sysAppVersionMapper.selectSysAppVersionList(sysAppVersion);
    }

    /**
     * 新增程序版本
     *
     * @param sysAppVersion 程序版本
     * @return 结果
     */
    @Override
    public int insertSysAppVersion(SysAppVersion sysAppVersion) {
        sysAppVersion.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        sysAppVersion.setCreateTime(DateUtils.getNowDate());
        sysAppVersion.setCreateBy(SecurityUtils.getUsername());
        return sysAppVersionMapper.insertSysAppVersion(sysAppVersion);
    }

    /**
     * 修改程序版本
     *
     * @param sysAppVersion 程序版本
     * @return 结果
     */
    @Override
    public int updateSysAppVersion(SysAppVersion sysAppVersion) {
        sysAppVersion.setUpdateTime(DateUtils.getNowDate());
        sysAppVersion.setUpdateBy(SecurityUtils.getUsername());
        return sysAppVersionMapper.updateSysAppVersion(sysAppVersion);
    }

    /**
     * 批量删除程序版本
     *
     * @param ids 需要删除的程序版本ID
     * @return 结果
     */
    @Override
    public int deleteSysAppVersionByIds(String[] ids) {
        return sysAppVersionMapper.deleteSysAppVersionByIds(ids);
    }

    /**
     * 删除程序版本信息
     *
     * @param id 程序版本ID
     * @return 结果
     */
    @Override
    public int deleteSysAppVersionById(String id) {
        return sysAppVersionMapper.deleteSysAppVersionById(id);
    }

    @Override
    public SysAppVersion selectMaxVersion() {
        return sysAppVersionMapper.selectMaxVersion();
    }
}
